module dycore_test

  use adv_case1_mod
  use sw_case2_mod
  use sw_case5_mod
  use sw_case6_mod
  use sw_case8_mod
  use sw_case10_mod
  use nh_case1_mod
  use nh_case2_mod
  use nh_case3_mod
  use nh_case5_mod
  use nh_case6_mod

contains

  subroutine adv_case(case_id, time_in_seconds, lon, lat, u, v, gh, ghs, g, radi)

    integer, intent(in ) :: case_id
    real(8), intent(in ) :: time_in_seconds
    real(8), intent(in ) :: lon
    real(8), intent(in ) :: lat
    real(8), intent(out), optional :: u
    real(8), intent(out), optional :: v
    real(8), intent(out), optional :: gh
    real(8), intent(out), optional :: ghs
    real(8), intent(out), optional :: g    ! Gravity acceleration
    real(8), intent(out), optional :: radi ! planet radius

    select case (case_id)
    case (1)
      call adv_case1 (time_in_seconds, lon, lat, u, v, gh, ghs, g, radi)
    case default
      stop 'Unknown test case!'
    end select

  end subroutine adv_case

  subroutine sw_case(case_id, lon, lat, u, v, gh, ghs, g, f, radi)

    integer, intent(in ) :: case_id
    real(8), intent(in ) :: lon
    real(8), intent(in ) :: lat
    real(8), intent(out), optional :: u
    real(8), intent(out), optional :: v
    real(8), intent(out), optional :: gh
    real(8), intent(out), optional :: ghs
    real(8), intent(out), optional :: g    ! Gravity acceleration
    real(8), intent(out), optional :: f    ! Coriolis parameter
    real(8), intent(out), optional :: radi ! planet radius

    select case (case_id)
    case (2)
      call sw_case2 (lon, lat, u, v, gh, ghs, g, f, radi)
    case (5)
      call sw_case5 (lon, lat, u, v, gh, ghs, g, f, radi)
    case (6)
      call sw_case6 (lon, lat, u, v, gh, ghs, g, f, radi)
    case (8)
      call sw_case8 (lon, lat, u, v, gh, ghs, g, f, radi)
    case (10)
      call sw_case10(lon, lat, u, v, gh, ghs, g, f, radi)
    case default
      stop 'Unknown test case!'
    end select

  end subroutine sw_case
  
  subroutine nh_case(case_id, lon, lat, z, rho, u, v, w, pt, mr, zs, rc, g, omg, radi, zt)
    integer, intent(in )           :: case_id
    real(8), intent(in )           :: lon
    real(8), intent(in )           :: lat
    real(8), intent(in ), optional :: z
    real(8), intent(out), optional :: rho
    real(8), intent(out), optional :: u
    real(8), intent(out), optional :: v
    real(8), intent(out), optional :: w
    real(8), intent(out), optional :: pt
    real(8), intent(out), optional :: mr
    real(8), intent(out), optional :: zs
    real(8), intent(out), optional :: rc
    real(8), intent(out), optional :: g
    real(8), intent(out), optional :: omg
    real(8), intent(out), optional :: radi
    real(8), intent(out), optional :: zt
    select case (case_id)
    case (1)
      call nh_case1(lon, lat, z, rho, u, v, w, pt, mr, zs, rc, g, omg, radi, zt)
    case (2)
      call nh_case2(lon, lat, z, rho, u, v, w, pt, mr, zs, rc, g, omg, radi, zt)
    case (3)
      call nh_case3(lon, lat, z, rho, u, v, w, pt, mr, zs, rc, g, omg, radi, zt)
    case (5)
      call nh_case5(lon, lat, z, rho, u, v, w, pt, mr, zs, rc, g, omg, radi, zt)
    case (6)
      call nh_case6(lon, lat, z, rho, u, v, w, pt, mr, zs, rc, g, omg, radi, zt)
    case default
      stop 'Unknown test case!'
    end select

  end subroutine nh_case

end module dycore_test
